<?php
	include_once '../pages/config.php';
?>
<?php
/**
 * return array(array('actionName' => 'string',
  	 					'productID'=> 'string',
  	 					'origion_price' => 'double',
  	 					'status'=> 'string(open,close)',
  	 					'timeleft' => 'long',
  	 					'aution_price'=> 'double',
  	 					'current_user_bid'=> 'userID: string',
  	 					'price_per_bid' => 'int'))
 */

$connection = mysql_connect ($host, $username, $password) or die ( $connect_error . mysql_error () );
$auctionList = ! empty ( $_POST ['auctions'] ) ? $_POST ['auctions'] : "";

$auctionList = explode ( ",", $auctionList );
foreach ( $auctionList as &$auction ) {
	$auction = ( int ) $auction;
}

$auctionList = implode ( ",", $auctionList );

mysql_select_db ( $db, $connection ) or die ( $connect_error . mysql_error () );
$result = @mysql_query ( "select * from auction_view WHERE auctionID IN (" . $auctionList . " )", $connection );
$arr = array ();
while ( $row = @mysql_fetch_assoc ( $result ) ) {
	
	$arr = array_merge ( $arr, array (
			array (
					'auctionID' => $row ['auctionID'],
					'auctionName' => $row ['name'],
					'productID' => $row ['productID'],
					'origion_price' => $row ['price'],
					'status' => $row ['status'],
					'timeleft' => strtotime ( $row ['end_time'] ) - strtotime ( 'now' ),
					'auction_price' => $row ['auction_price'],
					'current_user_bid' => $row ['current_user_bid'],
					'price_per_bid' => $row ['price_per_bid'] 
			) 
	) );
}

die ( json_encode ( $arr ) );
	
  	 


